<?php
//包含数据库配置文件
include '../../public/dbconfig.php';
//包含函数库文件
include '../../public/functions.php';
//调用函数 链接数据库
$link = con();
//接收要删除的id号
$cid = $_GET['cid'];

//查询该版块下是否有帖子
$tsql = "select id,uid,cid from ftiezi where cid={$cid}";
//执行sql
$tres = mysqli_query($link, $tsql);
//判断执行结果
if($tres && mysqli_num_rows($tres)){
	echo '<script>alert("该版块下有帖子不能删除");window.location.href="list.php";</script>';
	exit;
}else{
	//准备sql
	$sql = "delete from cate where id={$cid}";
	//执行sql
	$res = mysqli_query($link, $sql);
	//判断执行结果
	if($res){
		echo '<script>alert("删除成功");window.location.href="list.php";</script>';
	}else{
		echo '<script>alert("删除失败");window.location.href="list.php";</script>';
	}
}
//关闭数据库链接
mysqli_close($link);